package com.example.administrator.tiyuapp.NewsFragment.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.util.Log;

import com.example.administrator.tiyuapp.NewsFragment.beans.Channels;

import java.util.List;


/**
 * Created by Administrator on 2017/1/16.
 */
public class MyViewPagerAdapter extends FragmentStatePagerAdapter {
    private List<Fragment>fragments;
    private List<Channels>titles;
    public MyViewPagerAdapter(FragmentManager fm, List<Fragment>fragments, List<Channels>titles) {
        super(fm);
        this.fragments=fragments;
        this.titles=titles;

    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        Log.i("haha","数据数量为："+fragments.size());
        return fragments!=null?fragments.size():0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position).getName();


    }

//    @Override
//    public Fragment instantiateItem(ViewGroup container, int position) {
//                Fragment f=((Fragment) super.instantiateItem(container, position));
//        return f;
//    }

//    @Override
//    public int getItemPosition(Object object) {
//        return PagerAdapter.POSITION_NONE;
//    }
}
